Function Reference

_GUICtrlTreeViewSetState

Set the state of the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetState($i_treeview, $h_item, $i_state)

 

Parameters

$i_treeview controlID
$h_item item ID/handle to set the state for
$i_state the new item state (default 0 - no change) (See Remarks).

 

Return Value

Success: Returns TRUE.
Failure: Returns FALSE.

 

Remarks

    State table
State Value
$TVIS_SELECTED 2
$TVIS_CUT 4
$TVIS_DROPHILITED 8
$TVIS_BOLD 16
$TVIS_EXPANDED 32
$TVIS_EXPANDEDONCE 64
$TVIS_EXPANDPARTIAL 128

State values can BitOr'ed together as for example BitOr($TVIS_SELECTED, $TVIS_BOLD).

 

Related

_GUICtrlTreeViewGetState

 

Example


#include <GUIConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview, $h_search, $s_file, $h_item

$h_GUI = GUICreate("TreeView UDF Sample", 220, 220)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

GUISetState()

$h_search = FileFindFirstFile("C:\*.*")
If $h_search <> -1 Then
    While 1
        $s_file = FileFindNextFile($h_search)
        If @Error Then ExitLoop
        If Not StringInStr(FileGetAttrib("C:\" & $s_file), "D") Then ContinueLoop
        $h_item = _GUICtrlTreeViewInsertItem($treeview, $s_file)
        If StringInStr(FileGetAttrib("C:\" & $s_file), "H") Then
            _GUICtrlTreeViewSetState($treeview, $h_item, $TVIS_CUT)
        EndIf
    WEnd
EndIf

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Exit